# Maintainer: Gaetan Bisson <bisson@archlinux.org>
# Maintainer: Jan de Groot <jgc@archlinux.org>
# Contributor: mgushee

pkgname=djvulibre
pkgver=3.5.28
pkgrel=3
pkgdesc="Suite to create, manipulate and view DjVu ('déjà vu') documents"
url='http://djvu.sourceforge.net/'
arch=('x86_64')
license=('GPL2')
makedepends=('librsvg')
depends=('libtiff' 'hicolor-icon-theme')
source=(https://downloads.sourceforge.net/project/djvu/DjVuLibre/$pkgver/djvulibre-$pkgver.tar.gz
        djvulibre-check-image-size.patch
        djvulibre-check-input-pool.patch
        djvulibre-djvuport-stack-overflow.patch
        djvulibre-integer-overflow.patch
        djvulibre-unsigned-short-overflow.patch)
sha256sums=('fcd009ea7654fde5a83600eb80757bd3a76998e47d13c66b54c8db849f8f2edc'
            '5cd3bdedc9ba82af541e1fc0bb6fabdc77c7fc43ee6bd15f9c7cca9d39d53c82'
            'd938cb05ac37b2f3f9602de6d148307e4164ee8a6f89fb6d81d5ed100fbc368b'
            '73e476cdb8af46bf94b208b9170679aaba165d54247d435e6a58e874ae85109c'
            '9e6d8b94d922ba382702ec4f878c06293eb546827e40a7de5221cb21c52d3d23'
            '7ea0926757adaaff61b5622b2ee88d4af55fec5235183828337005852118f97f')

prepare() {
# Security fixed from Fedora
  for _patch in djvulibre*.patch; do
    patch -d $pkgname-$pkgver -p1 < $_patch
  done
}

build() {
	cd ${pkgname}-${pkgver}
	./configure --prefix=/usr --disable-desktopfiles
	make
}

package() {
	cd ${pkgname}-${pkgver}
	make DESTDIR="${pkgdir}" install
	for sz in 22 32 48 64; do
		install -Dm644 desktopfiles/prebuilt-hi${sz}-djvu.png "${pkgdir}/usr/share/icons/hicolor/${sz}x${sz}/mimetypes/image-vnd.djvu.mime.png"
	done
}
